package com.leyou.item.service;

import com.leyou.common.enums.ExceptionEnum;
import com.leyou.common.exceptions.LyException;
import com.leyou.item.pojo.Item;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @author Eric
 * @version v1.0
 * @package com.leyou.item.service
 * @date 2019/6/22 15:47
 * @description:
 **/
@Service
public class ItemService {

    public Item saveItem(Item item){

        if(item.getPrice()==null){
           throw new LyException(ExceptionEnum.PRICE_CANNOT_BE_NULL);
        }

        int id = new Random().nextInt(100);
        item.setId(id);
        return item;
    }
}
